package com.jisuan.contract.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.jisuan.contract.common.utils.PageResult;
import com.jisuan.contract.common.utils.PageUtils;
import com.jisuan.contract.common.utils.Query;
import com.jisuan.contract.dao.FirstPartyDao;
import com.jisuan.contract.entity.FirstPartyEntity;
import com.jisuan.contract.service.FirstPartyService;
import org.springframework.stereotype.Service;

import java.util.Map;


@Service("firstPartyService")
public class FirstPartyServiceImpl extends ServiceImpl<FirstPartyDao, FirstPartyEntity> implements FirstPartyService {

    @Override
    public PageResult queryPage(Map<String, Object> params, FirstPartyEntity firstParty)
    {
        LambdaQueryWrapper<FirstPartyEntity> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.like(
                firstParty.getFirstPartyName() != null,
                FirstPartyEntity::getFirstPartyName, firstParty.getFirstPartyName()
        );
        IPage<FirstPartyEntity> page = this.page(
                new Query<FirstPartyEntity>().getPage(params),
                queryWrapper
        );
        return new PageResult(page);
    }

}